<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class HomeAddUserValidata extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
     public function authorize()
     {
         return true;
     }

     /**
      * Get the validation rules that apply to the request.
      *
      * @return array
      */
     public function rules()
     {
         return [
             'username'              => 'required|min:2|max:16',
             'password'              => 'required|confirmed|min:6',
             'password_confirmation' => 'required',
             'phone'                 => ['required', 'unique:shop_home_users','regex:/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/u'],
             'code'                  => 'required|min:6|max:6',
         ];
     }

     public function messages()
     {
         return [
             'code.required'                  => '验证码不能为空',
             'code.max'                       => '验证码不能超过6位',
             'code.min'                       => '验证码不能小于6位',
             'username.required'              => '用户名不能为空',
             'phone.required'                 => '手机号码不能为空',
             'phone.unique'                   => '手机号已注册',
             'username.min'                   => '用户名不能小于2',
             'username.max'                   => '用户名不能大于16',
             'password.required'              => '密码不能为空',
             'passname.min'                   => '密码不能少于6位',
             'phone.regex'                    => '手机号码不正确',
             'password_confirmation.required' => '确认密码不能为空',
             'password_confirmation.min'      => '密码不能少于6位',
         ];
     }
}
